Skip to content

Feature/add assistant name support #4047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

huidongyin
Copy link
Contributor

Overview

This PR adds name property support to AssistantMessage to enable building multi-agent systems in Spring AI. This enhancement allows assistants to be distinguished by name, making it easier to share global context across different AI assistants.

Key Features

  • Multi-agent System Support: Add name field to AssistantMessage for multi-agent system support
  • Backward Compatibility: Add new constructors with name parameter while maintaining backward compatibility
  • Comprehensive Integration: Update all major AI provider implementations to pass name to API calls

Technical Implementation

Core Changes

  • Add name field to AssistantMessage class
  • Update equals, hashCode, and toString methods to include name
  • Add new constructors with name parameter for backward compatibility
  • Update Prompt class to properly copy name property

AI Provider Updates

Updated the following AI provider implementations to support name property:

  • OpenAI ChatModel - Direct API support
  • DeepSeek ChatModel - Enhanced with name support
  • MiniMax ChatModel - Name parameter integration
  • Mistral AI ChatModel - Assistant name support
  • ZhiPu AI ChatModel - Name field integration
  • Azure OpenAI ChatModel - Reflection-based dynamic support

Memory Repository Updates

  • Updated Neo4j chat memory repository to handle name property
  • Updated Cassandra chat memory repository for name support
  • Enhanced DeepSeekAssistantMessage constructors to support name parameter

Test Coverage

  • Added comprehensive test coverage for name property functionality
  • Tests cover constructor variations, equality comparisons, and serialization
  • All existing tests continue to pass

Change Statistics

  • Files Changed: 12 files
  • Lines Added: 197 insertions
  • Lines Removed: 13 deletions
  • Test Coverage: 100% for new functionality

Backward Compatibility

This change is fully backward compatible:

  • Existing code continues to work without modification
  • New name parameter is optional in all constructors
  • All existing API contracts remain unchanged

Usage Examples

// Basic usage (backward compatible)
AssistantMessage message = new AssistantMessage("Hello");

// With name support for multi-agent systems
AssistantMessage namedMessage = new AssistantMessage("Hello", "assistant-1");

// Using builder pattern
AssistantMessage builtMessage = AssistantMessage.builder()
    .content("Hello")
    .name("assistant-1")
    .build();

Quality Assurance

  • All tests pass
  • Spring Java format applied
  • Backward compatibility maintained
  • Comprehensive test coverage
  • Code review ready

Related Issue

Closes #[3737] - AssistantMessage doesn't support 'name' property #3737


…\n\n- Add name field to AssistantMessage for multi-agent system support\n- Add new constructors with name parameter for backward compatibility\n- Update equals, hashCode, and toString methods to include name\n- Add comprehensive test coverage for name property functionality\n- Update all AI provider implementations to pass name to API calls:\n * OpenAI ChatModel\n * DeepSeek ChatModel \n * MiniMax ChatModel\n * Mistral AI ChatModel\n * ZhiPu AI ChatModel\n * Azure OpenAI ChatModel (with reflection-based dynamic support)\n- Update Prompt class to properly copy name property\n- Update memory repository implementations (Neo4j, Cassandra)\n- Update DeepSeekAssistantMessage constructors to support name parameter\n- Apply Spring Java format to all modified files\n\nThis enhancement enables building multi-agent systems by allowing\nassistants to be distinguished by name, making it easier to share\nglobal context across different AI assistants.

Signed-off-by: huidong.yin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant